import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Canvas;

public class MainMenu extends Canvas{
	private Display display;
	private byte yselect, menuselect;
	private Exit exit;
	private Help help;
	private Options options;
	private About about;
	private PlayMenu playmenu;
	public MainMenu(GameMIDlet midlet, Display display){
		this.display = display;
		yselect = 25;
		menuselect = 1;
		exit = new Exit(midlet, this, display);
		help = new Help(this, display);
		options = new Options(this, display);
		about = new About(this,display);
		playmenu = new PlayMenu(this, display);
		setFullScreenMode(true);
	}
	public void paint(Graphics g){
		if(Option.language == true){
			g.setColor(255, 255, 255);
			g.fillRect(0, 0, 128, 160);			
			//g.drawLine(64,0,64,160);
			g.setColor(50,255,150);
			g.fillRect(0, yselect - 2, 128, 15);
			g.setColor(0, 0, 0);
			g.drawString("Choi", 54, 25, 0);
			g.drawString("Diem Cao", 43, 40,0);
			g.drawString("Tuy Chinh", 40, 55, 0);
			g.drawString("Tro Giup", 45, 70, 0);
			g.drawString("Thong Tin", 39, 85, 0);
			g.drawString("Thoat", 49, 100, 0);
		}
		else{
			g.setColor(255, 255, 255);
			g.fillRect(0, 0, 128, 160);
			g.setColor(50,255,150);
			g.fillRect(0, yselect - 2, 128, 15);
			g.setColor(0, 0, 0);
			//g.drawLine(64,0,64,160);			
			g.drawString("Play", 54, 25, 0);
			g.drawString("Hight Scores", 33, 40,0);
			g.drawString("Options", 46, 55, 0);
			g.drawString("Help", 54, 70, 0);
			g.drawString("About", 49, 85, 0);
			g.drawString("Exit", 55, 100, 0);
		}
	}
	protected void keyPressed(int code){
		//Xy ly hien thi khi nhan len trong main menu
		if((code == 50)||(code == -1)){		
			yselect -= 15;
			menuselect --;
			if(yselect < 25){
				yselect = 100;
				menuselect = 6;
			}
		}
		//Xy ly hien thi khi nhan xuong trong main menu
		if((code == 56)||(code == -2)){
			yselect += 15;
			menuselect ++;
			if(yselect > 100){
				yselect = 25;
				menuselect = 1;
			}
		}
		if(((code == 53)||(code == -5))&&(menuselect == 6))
			display.setCurrent(exit);		
		if(((code == 53)||(code == -5))&&(menuselect == 5))
			display.setCurrent(about);
		if(((code == 53)||(code == -5))&&(menuselect == 4))
			display.setCurrent(help);
		if(((code == 53)||(code == -5))&&(menuselect == 3))
			display.setCurrent(options);
		if(((code == 53)||(code == -5))&&(menuselect == 1))	
			display.setCurrent(playmenu);	
		repaint();
	}
}